Suppose you are working on a module. I was thinking if you found the max ID number from HistorySession and looked for history of interest in History matching said ID number, that would be the way to go. To my surprise I found nothing. This is because HistorySession starts with 0 and History starts with 1 ("can't we all get along?").
int getHistoryNoForThisSession() {
int historyNo = -1; // -1 means something wrong
HistorySession historySession = (HistorySession null);
for historySession in current Module do { /* notta */ }
// is there as Last() function or similar?
if (!null(historySession)) {
//----------------------------------------------------------------------
// Empirical obsevation:
// HistorySession numbering is 0 .. (N-1) with no gaps
// History.sessionNo numbering is 1..N with gaps if no history
// To bridge the two domains we must add 1 from HistorySession to
// make a correspondence (???).
//----------------------------------------------------------------------
historyNo = number(historySession) + 1;
}
return historyNo;
}
string getIntSkipListKeysAsCsvStr(Skip skip) {
string retVal = "";
if (null(skip)) {
// nothing;
} else {
Buffer b = create();
int element;
for element in skip do {
b += "" (int key skip) "";
b += ", ";
}
retVal = stringOf(b[0:(length(b) - 3)]);
delete(b);
}
return retVal;
}
void sessionNoDiscovery() {
Skip numberSkip = create();
Skip sessionNoSkip = create();
HistorySession historySession = (HistorySession null);
for historySession in current Module do {
// Store unique numbers as set
put(numberSkip, number(historySession), 0); // no data, just key
}
History history = (History null);
for history in current Module do {
// Store unique numbers as set
put(sessionNoSkip, history.sessionNo, 0); // no data, just key
}
print("The History.historyNo for the current session is " (getHistoryNoForThisSession()) "\n\n");
print("Unique number() on members in HistorySession gives: " getIntSkipListKeysAsCsvStr(numberSkip) "\n");
print("Unique history.sessionNo on members in History gives: " getIntSkipListKeysAsCsvStr(sessionNoSkip) "\n");
delete(numberSkip);
delete(sessionNoSkip);
}
// Call it here:
sessionNoDiscovery();
SystemAdmin - Fri Jun 11 11:53:56 EDT 2010 |
Re: History vs. HistorySession, Is ID Numbering Offset by 1? In the history tab in Module Properties the session number seems be +1 compared to number(HistorySession). /Anders |
Re: History vs. HistorySession, Is ID Numbering Offset by 1? I've got a HistoryReport.dxl script. The GUI and the DXL dumping history for the module agree on which Session is associated with which each History. Your numbers are off by one because you are adding one to the Sesssion Number in function getHistoryNoForThisSession(). Did I miss something? The following gets the current Session number, which is null when the module is open Read. Module m = current() HistorySession hsCurr = current(m) if (null hsCurr) // then print "Current Session is null\n" else print "Current Session = " number(hsCurr) "\n"
|
Re: History vs. HistorySession, Is ID Numbering Offset by 1? llandale - Tue Jun 15 14:36:33 EDT 2010 I've got a HistoryReport.dxl script. The GUI and the DXL dumping history for the module agree on which Session is associated with which each History. Your numbers are off by one because you are adding one to the Sesssion Number in function getHistoryNoForThisSession(). Did I miss something? The following gets the current Session number, which is null when the module is open Read. Module m = current() HistorySession hsCurr = current(m) if (null hsCurr) // then print "Current Session is null\n" else print "Current Session = " number(hsCurr) "\n"
OK. I think I see what you are getting at, even though you didn't get at it clearly. Find a small module, edit it, make a change, save and close, then open the module Read. Run the following
HistorySession hs
History his
print "Session\tDate\t\tWho\t\tMode\t<<-- for Sessions\n"
for hs in (current Module) do
{ print number(hs) "\t" when(hs) "\t" who(hs) "\t" mode(hs) "\n"
}
print "Session\tDate\t\tAuthor\t\tHistoryType\t<-- for History\n"
for his in (current Module) do
{ print (his.sessionNo) "\t" (his.date) "\t" (his.author) "\t" (goodStringOf(his.type) )"\n"
}
For me, prints this:
Session Date Who Mode <<-- for Sessions
0 06/15/10 13:38:27 landalo-Admin 0
1 06/15/10 13:41:26 landalo-Admin 0
2 06/15/10 13:43:41 landalo-Admin 0
3 06/15/10 13:56:45 landalo-Admin 2
4 06/15/10 13:56:52 landalo-Admin 0
5 06/15/10 13:56:59 landalo-Admin 2
Session Date Author HistoryType <-- for History
1 06/15/10 13:38:27 landalo-Admin Create Module
1 06/15/10 13:39:33 landalo-Admin Create Object
3 06/15/10 13:48:14 landalo-Admin Modify Object
6 06/15/10 13:57:11 landalo-Admin Modify Object
|
Re: History vs. HistorySession, Is ID Numbering Offset by 1? llandale - Tue Jun 15 15:06:09 EDT 2010 OK. I think I see what you are getting at, even though you didn't get at it clearly. Find a small module, edit it, make a change, save and close, then open the module Read. Run the following
HistorySession hs
History his
print "Session\tDate\t\tWho\t\tMode\t<<-- for Sessions\n"
for hs in (current Module) do
{ print number(hs) "\t" when(hs) "\t" who(hs) "\t" mode(hs) "\n"
}
print "Session\tDate\t\tAuthor\t\tHistoryType\t<-- for History\n"
for his in (current Module) do
{ print (his.sessionNo) "\t" (his.date) "\t" (his.author) "\t" (goodStringOf(his.type) )"\n"
}
For me, prints this:
Session Date Who Mode <<-- for Sessions
0 06/15/10 13:38:27 landalo-Admin 0
1 06/15/10 13:41:26 landalo-Admin 0
2 06/15/10 13:43:41 landalo-Admin 0
3 06/15/10 13:56:45 landalo-Admin 2
4 06/15/10 13:56:52 landalo-Admin 0
5 06/15/10 13:56:59 landalo-Admin 2
Session Date Author HistoryType <-- for History
1 06/15/10 13:38:27 landalo-Admin Create Module
1 06/15/10 13:39:33 landalo-Admin Create Object
3 06/15/10 13:48:14 landalo-Admin Modify Object
6 06/15/10 13:57:11 landalo-Admin Modify Object
Before closing the issue I have a related question. Often there are several ways to solve a problem but sometimes one is easier or more reliable than the other. Suppose: 1) A user opens a module in exclusive edit mode. 2) The desire is to: --> a) Set an int variable (call it mySessionId) that with certainty corresponds to the session the user opened the module with. --> b) Upon some arbitrary event (menu, button press, module close) gather some information from History that were associated with the current module edit session by this user. I was thinking that I could: --> a) set mySessionId to the max id from HistorySession --> b) increment mySessionId by 1 --> c) probe History for items of interest with (history.sessionNo == mySessionId) Is there a more reliable way to do this? Stated another way, what is the best way to discover the session ID you are currently "Exclusive Editing" under? Now I'm concerned about what happens if someone else opens the module read-only after I started the exclusive edit session. I'm scared of getting the wrong session ID. |
Re: History vs. HistorySession, Is ID Numbering Offset by 1? SystemAdmin - Tue Jun 15 16:48:28 EDT 2010
Louie, I did not know about the mode(HistorySession) because it is not documented in the DOORS help file (in V8.2 anyway)(not that this is a rare find).
int getHistoryNoForThisExclusiveEditSession() {
int historyNo = -1; // - means something wrong or none found
int historySessionNo = -1; // - means something wrong or none found
HistorySession historySession = (HistorySession null);
for historySession in current Module do {
if (mode(historySession) == 0) { // exclusive edit
historySessionNo = number(historySession);
}
}
// is there as Last() function or similar?
if (historySessionNo > -1) {
//----------------------------------------------------------------------
// Empirical observation:
// HistorySession numbering is 0 .. (N-1) with no gaps
// History.sessionNo numbering is 1..N with gaps if no history
// To bridge the two domains we must add 1 from HistorySession to
// make a correspondance.
//----------------------------------------------------------------------
historyNo = historySessionNo + 1;
}
return historyNo;
}
Since there is no HistorySession increment for read-only access, there is need to worry.
"Every time a DOORS module is opened in either edit or shareable mode, a session summary is saved."
"You can access this information using the functions that act on an object of type HistorySession." |
Re: History vs. HistorySession, Is ID Numbering Offset by 1? SystemAdmin - Tue Jun 15 16:48:28 EDT 2010 Now let me guess. You are looking for unsaved edits in the current session, wondering if perhaps you should close without saving? Don't know how to do that. I see that the dateAndTime of the module's Last Modified On attribute is updated when you change, not udpated when you save. If you discard edits that value returns to its earlier value.
|
Re: History vs. HistorySession, Is ID Numbering Offset by 1? llandale - Tue Jun 15 19:41:53 EDT 2010
Sorry, I focused on your second post and glanced over the first post. The number(hsCurr) from below seems fine. Module m = current() HistorySession hsCurr = current(m) if (null hsCurr) // then print "Current Session is null\n" else print "Current Session = " number(hsCurr) "\n"
|